import { createSlice } from "@reduxjs/toolkit";

// 创建切片
const UserSlice = createSlice({
    name: "UserSlice", //用户标记slice的名词
    // 定义初始状态
    initialState: {
        token: "",
        userInfo: {},
    },
    // 定义reducer
    reducers: {
        setUserStore(state, { payload }) {
            state.token = payload.token;
            state.userInfo = payload.userInfo;
        },
    },
});

// 导出action
export const { setUserStore } = UserSlice.actions;

// 导出reducer
export default UserSlice.reducer;
